#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QApplication>
#include <QQmlContext>
#include <QQuickView>
#include <QQuickItem>
//#include <QQuickStyle>
#include <QUrl>
#include <QDebug>
#include <QFile>
#include <QPalette>
//#include "ukuimenubackground.h"
//#include "menu/menu.h"
//#include "menu/dtk/dpopupwindowhandle_p.h"
//#include "menu/dtk/dquickbehindwindowblur_p.h"

// MenuModel.h
#include "MenuModel.h"

int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QGuiApplication app(argc, argv);

//    QQuickStyle::setStyle("org.kde.desktop");
//    QQuickStyle::setStyle("org.ukui.style");
    QQuickView view;

    QFile file;
//    /usr/share/icons/ukui-icon-theme-default/scalable/actions
    qDebug() << " file exists..." << QFile::exists("/usr/share/icons/ukui-icon-theme-default/scalable/actions/ukui-end-symbolic.svg");
//    // 创建QWidget控件
//        UKUIMenuBackGround  *myWidget = new UKUIMenuBackGround();

//    QQmlApplicationEngine engine;
//    // 使用createWindowContainer封装QWidget
////    QQuickItem *container = view.rootContext()->engine()->createWindowContainer(myWidget);
//    qmlRegisterType<UKUIQQC2Style::Menu>("ukui.menu", 1, 0, "MyMenu");
//    qmlRegisterType<UKUIQQC2Style::Data>("ukui.menu", 1, 0, "MyData");

//    engine.rootContext()->setContextProperty("myWidgetContainer", myWidget);
//    qmlRegisterType<UKUIMenuBackGround>("ukui.menu", 1, 0, "UKUIMenuBackGround");


//    qmlRegisterType<DPopupWindowHandle>("ukui.dtk", 1, 0, "PopupHandle");
//    //qmlRegisterType<DQuickBehindWindowBlur>("ukui.dtk", 1, 0, "BehindWindowBlur");

////    qmlRegisterType<BackgroundItem>("CustomComponents", 1, 0, "BackgroundItem");


    QObject::connect(&app, &QGuiApplication::fontChanged, [](const QFont &font){
        qDebug() << "app font changeddd..." << font;
    });


    qmlRegisterType<MenuModel>("Custom.Models", 1, 0, "MenuModel");

    QQmlApplicationEngine engine;

    for(QString path : engine.importPathList())
        qDebug() << "importPathList...." << path;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);

    qDebug() << "kradius-window...." << app.property("kradius-window").toInt();
    qDebug() << "base color..." << qApp->palette().color(QPalette::Highlight);
    QUrl u("qrc:/1234.png");
    qDebug() << u.scheme() << u.path() << u.toLocalFile();

    return app.exec();
}
